import {
  Column,
  CreateDateColumn,
  Entity,
  JoinTable,
  ManyToMany,
  ManyToOne,
  OneToOne,
  PrimaryGeneratedColumn,
  UpdateDateColumn,
} from 'typeorm';
import { Enterprise } from './enterprise.entity';
import { application } from 'express';

@Entity({ name: 'patent' })
export class Patent {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({
    length: 255,
    comment: '专利名称',
  })
  name: string;

  @Column({
    type: 'timestamp',
    nullable: true,
    comment: '申请日期',
    name: 'application_date',
  })
  applicationDate: Date;

  @Column({
    type: 'timestamp',
    nullable: true,
    comment: '注册日期',
    name: 'registration_date',
  })
  registrationDate: Date;

  @Column({
    length: 255,
    nullable: true,
    comment: '申请人',
  })
  applicant: string;

  @Column({ length: 50, nullable: true, comment: '专利类型' })
  patentType: string;

  @Column({
    type: 'text',
    nullable: true,
    comment: '专利摘要',
  })
  abstract: string;

  @ManyToOne(() => Enterprise, (enterprise) => enterprise.patents, {
    onDelete: 'CASCADE',
    onUpdate: 'CASCADE',
  })
  enterprise: Enterprise; // 专利所属的企业

  @CreateDateColumn({ type: 'timestamp', comment: '创建时间' })
  createTime: Date;

  @UpdateDateColumn({ type: 'timestamp', comment: '更新时间' })
  updateTime: Date;
}
